package net.realsee.domain.wcs.rcs.hik.v4;

import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import lombok.Data;

/**
 * HIK回调实体
 *
 * @author 孙正华
 * @since 2023/10/11 10:04
 */
@Data
public class HikRcsV4AgvCallback {

    /**
     * 任务号
     */
    private String robotTaskCode;

    /**
     * 当前执行任务的机器人唯一标识。
     */
    private String singleRobotCode;

    /**
     * 扩展内容
     */
    private Extra extra;

    @Data
    public static class Extra {

        /**
         * 明细
         */
        Item values;
    }

    @Data
    public static class Item {
        private String slotCategory;
        private String slotCode;
        private String slotName;

        private String carrierCategory;
        private String carrierType;
        private String carrierCode;

        private String method;

        private String mapCode;
        private String carrierDir;
        private String x;
        private String y;
    }

    public String getCurrentTaskCode() {
        if (StrUtil.isNotBlank(this.taskCode)) {
            return this.taskCode;
        }
        if (StrUtil.isNotBlank(this.getRobotTaskCode())) {
            return this.robotTaskCode;
        }
        return StrUtil.EMPTY;
    }

    public String getCallbackMethod() {
        // 海康定制化开发，把method放到了最外层
        if (StrUtil.isNotBlank(this.method)) {
            return this.method;
        }
        if (ObjectUtil.isNull(this.extra) || ObjectUtil.isNull(this.extra.values)) {
            return StrUtil.EMPTY;
        }
        return this.extra.values.getMethod();
    }

    public void setCallbackMethod(String method) {
        if (ObjectUtil.isNull(this.extra) || ObjectUtil.isNull(this.extra.values)) {
            return;
        }
        this.extra.values.setMethod(method);
    }

    public String getCurrentPositionCode() {
        if (ObjectUtil.isNull(this.extra) || ObjectUtil.isNull(this.extra.values)) {
            return StrUtil.EMPTY;
        }
        return this.extra.values.getSlotName();
    }

    public String getCarrierCode() {
        if (ObjectUtil.isNull(this.extra) || ObjectUtil.isNull(this.extra.values)) {
            return StrUtil.EMPTY;
        }
        return this.extra.values.getCarrierCode();
    }

    /*
    --------------------------------------------以下参数是偏差调整特有的，海康定制化开发--------------------------------------------
     */
    private String taskCode;
    private String method;
    private String eqptCode;

}
